import pluginJson from '../../plugin_sticker/PluginConfig.json';
export const DB_FD = {
  DB_NAME: 'stickers_db.db',
  DB_DEFAULT_NAME: 'system_stickers_db.db',
  DB_NEW_NAME: 'stickers_db_new.db',
  DB_VERSION: '1.0',
  STICKER_GROUP_TABLE: 'StickerGroup',
  STICKER_TABLE: 'Sticker',
  STICKER_LOCATION: 'plugins/' + pluginJson.pluginID + '/',
};
export const DB_ST = {
  STICKER_GROUP_TABLE_ST: `CREATE TABLE IF NOT EXISTS ${DB_FD.STICKER_GROUP_TABLE} (
        id INTEGER PRIMARY KEY AUTOINCREMENT,
        name TEXT NOT NULL,
        num INTEGER,
        path TEXT,
        thumb_sticker TEXT,
        dir_name TEXT NOT NULL,
        create_time INTEGER,
        update_time INTEGER
      );`,
  STICKER_TABLE_ST: `
      CREATE TABLE IF NOT EXISTS ${DB_FD.STICKER_TABLE} (
        id INTEGER PRIMARY KEY AUTOINCREMENT,
        name TEXT NOT NULL,
        path TEXT NOT NULL,
        thumb_sticker TEXT NOT NULL,
        sticker_group_id TEXT NOT NULL,
        create_time INTEGER NOT NULL,
        update_time INTEGER NOT NULL,
        use_time INTEGER,
        num INTEGER,
        md5 TEXT NOT NULL
     );`,
  ADD_STICKER_GROUP_ST: `INSERT INTO ${DB_FD.STICKER_GROUP_TABLE} (name, num, path, dir_name,create_time,update_time) VALUES (?,?,?,?,?,?)`,
  ADD_STICKER_ST: `INSERT INTO ${DB_FD.STICKER_TABLE} (name, path, thumb_sticker, sticker_group_id, create_time, update_time, use_time, num, md5) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
  SELECT_STICKER_GROUP_ST: `SELECT * FROM ${DB_FD.STICKER_GROUP_TABLE}`,
  SELECT_STICKER_ST: `SELECT * FROM ${DB_FD.STICKER_TABLE} WHERE sticker_group_id = ? ORDER BY update_time DESC;`,
  SELECT_STICKER_ORDER_ID: `SELECT * FROM ${DB_FD.STICKER_TABLE} WHERE sticker_group_id = ? ORDER BY id ASC;`,
  SELECT_STICKER_DS_ST: `SELECT * FROM ${DB_FD.STICKER_TABLE} WHERE use_time != 0 ORDER BY use_time DESC;`,
  SELECT_STICKER_GROUP_UPDATE_ST: `SELECT * FROM ${DB_FD.STICKER_GROUP_TABLE} ORDER BY update_time DESC;`,
  SELECT_STICKER_GROUP_CREATE_ST: `SELECT * FROM ${DB_FD.STICKER_GROUP_TABLE} ORDER BY create_time DESC;`,
  SELECT_NAME_ST: `SELECT * FROM ${DB_FD.STICKER_TABLE} WHERE name = ?`,
  SELECT_ID_ST: `SELECT * FROM ${DB_FD.STICKER_TABLE} WHERE id = ?`,
  SELECT_GROUP_NAME_ST: `SELECT * FROM ${DB_FD.STICKER_GROUP_TABLE} WHERE name = ?`,
  SELECT_GROUP_ID_ST: `SELECT * FROM ${DB_FD.STICKER_GROUP_TABLE} WHERE id = ?`,
  SELECT_STICKER_GROUP_ID_ST: `SELECT * FROM ${DB_FD.STICKER_TABLE} WHERE sticker_group_id = ?`,
  UPDATE_GROUP_STICKER_ST: `UPDATE ${DB_FD.STICKER_GROUP_TABLE} SET name = ? WHERE id = ?`,
  UPDATE_GROUP_STICKER_UPDATE_ST: `UPDATE ${DB_FD.STICKER_GROUP_TABLE} SET update_time = ? WHERE id = ?`,
  UPDATE_GROUP_STICKER_THUMB_ST: `UPDATE ${DB_FD.STICKER_GROUP_TABLE} SET thumb_sticker = ? WHERE id = ?`,
  UPDATE_STICKER_NM_ST: `UPDATE ${DB_FD.STICKER_TABLE} SET name = ?, path = ? WHERE id = ?`,
  UPDATE_STICKER_UPDATE_TIME_ST: `UPDATE ${DB_FD.STICKER_TABLE} SET update_time = ? WHERE id = ?`,
  UPDATE_STICKER_USE_TIME_ST: `UPDATE ${DB_FD.STICKER_TABLE} SET use_time = ? WHERE id = ?`,
  UPDATE_STICKER_ID_ST: `UPDATE ${DB_FD.STICKER_TABLE} SET sticker_group_id = ? WHERE id = ?`,
  UPDATE_STICKER_MOVE_ST: `UPDATE ${DB_FD.STICKER_TABLE} SET name = ?, path = ?, thumb_sticker = ?, sticker_group_id = ?, update_time = ? WHERE id = ?`,
  UPDATE_STICKER_MOVE_TH_ST: `UPDATE ${DB_FD.STICKER_TABLE} SET path = ?, WHERE id = ?`,
  UPDATE_STICKER_MOVE_THUM_ST: `UPDATE ${DB_FD.STICKER_TABLE} SET thumb_sticker = ?, WHERE id = ?`,
  UPDATE_STICKER_MOVE_TIME_ST: `UPDATE ${DB_FD.STICKER_TABLE} SET  update_time = ? WHERE id = ?`,
  DELETE_GROUP_STICKERS_ST: `DELETE FROM ${DB_FD.STICKER_GROUP_TABLE} WHERE id IN `,
  DELETE_STICKERS_ST: `DELETE FROM ${DB_FD.STICKER_TABLE} WHERE id IN `,
  SELECT_STICKER_GROUP_PAGE_ST: `SELECT * FROM ${DB_FD.STICKER_GROUP_TABLE} ORDER BY update_time DESC LIMIT ? OFFSET ?`,
  SELECT_STICKER_PAGE_ST: `SELECT * FROM ${DB_FD.STICKER_TABLE} WHERE sticker_group_id = ? ORDER BY update_time DESC LIMIT ? OFFSET ?;`,
  SELECT_STICKER_LIKE_ST: `SELECT * FROM ${DB_FD.STICKER_TABLE} WHERE LOWER(name) LIKE LOWER(?)`,
  SELECT_STICKER_LIKE_ST_BY_GROUP_ID: `SELECT * FROM ${DB_FD.STICKER_TABLE} WHERE LOWER(name) LIKE LOWER(?) AND sticker_group_id = ?`,
  SELECT_STICKER_GROUP_LIKE_ST: `SELECT * FROM ${DB_FD.STICKER_GROUP_TABLE} WHERE name LIKE ?`,
  SELECT_STICKER_GROUP_LIKE_WITHOUT_ID_ST: `SELECT * FROM ${DB_FD.STICKER_GROUP_TABLE} WHERE name LIKE ? AND id != ?`,
  SELECT_STICKER_LIKE_WITHOUT_ID_ST: `SELECT * FROM ${DB_FD.STICKER_TABLE} WHERE name LIKE ? AND id != ?`,
};
